package com.movie.api.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.movie.api.context.LoginContext;
import com.movie.api.mapper.UserMapper;
import com.movie.api.model.entity.OrderVIP;
import com.movie.api.model.entity.User;
import com.movie.api.service.AliPayService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Api(tags = "订单接口")
@RequestMapping("/api/order")
public class OrderController {

    @Resource
    private UserMapper userMapper;

    @Resource
    private AliPayService aliPayService;

    // 不用Service了
    @GetMapping("/orderVip")
    public OrderVIP getById() {
        String name = LoginContext.getName();
        QueryWrapper<User> userQueryWrapper = new QueryWrapper<User>();
        userQueryWrapper.eq("username", name);
        User user = userMapper.selectOne(userQueryWrapper);
        String userId = user.getId();
        return aliPayService.getById(userId);
    }

}
